package com.gzx.plugin.tjzy.xxljob;

import com.gzx.plugin.tjzy.modular.call.receipt.service.GzxHtCallReceiptBusinessService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import vip.xiaonuo.common.tenant.TenantContext;

import java.util.Arrays;
import java.util.List;

/**
 * @author xbl
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class QWechatEmailXxlJob {

    private final GzxHtCallReceiptBusinessService htCallReceiptBusinessService;

    //企业微信定时发邮件
    @XxlJob("noticeQWechatEmailJob")
    public void noticeQWechatEmailJob() {
        TenantContext.ignoreHandle(() -> {
            log.info("企业微信定时发邮件开始");
            List<String> toAddress = Arrays.stream(XxlJobHelper.getJobParam().split(",")).toList();
            htCallReceiptBusinessService.sendEmail(toAddress);
            log.info("企业微信定时发邮件成功");
        });
    }
}
